package com.ruoyi.web.controller.okr;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.MakeOrderNumUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.OkrCycle;
import com.ruoyi.system.domain.OkrInfo;
import com.ruoyi.system.domain.OkrSynergy;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.resultMapper.SynergyOkrInfo;
import com.ruoyi.system.service.IOkrCycleService;
import com.ruoyi.system.service.IOkrInfoService;
import com.ruoyi.system.service.IOkrSynergyService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.view.UserZtree;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 协同关系Controller
 * 
 * @author OKR
 * @date 2020-05-07
 */
@Controller
@RequestMapping("/okr/synergy")
public class MyOkrSynergyController extends BaseController
{
    private String prefix = "okr";

    @Autowired
    private IOkrInfoService okrInfoService;


    @Autowired
    private IOkrCycleService okrCycleService;


    @Autowired
    private IOkrSynergyService okrSynergyService;

    @Autowired
    private ISysDeptService deptService;

    @RequiresPermissions("okr:synergy:view")
    @GetMapping()
    public String synergy(ModelMap mmap)
    {
        List<OkrCycle> list = okrCycleService.selectOkrUseCycleList();
        mmap.put("cycleList", list);
        return prefix + "/synergyInfo";
    }

    /**
     * 查询OKR信息列表
     */
    @RequiresPermissions("okr:synergy:list")
    @PostMapping("/list")
    @ResponseBody
    public List<SynergyOkrInfo> list(OkrInfo okrInfo)
    {
        Long userId = ShiroUtils.getUserId();
        List<SynergyOkrInfo> list = okrInfoService.querySynergyOkrInfoListByUserId(okrInfo,userId);
        return list;
    }
}
